﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="CustomerActive.aspx.cs" Inherits="_Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Customer Active</title>
    <%--<script type="text/javascript" src="assets/js/jquery.js"></script>

    <script type='text/javascript' src="assets/js/jquery.min.js"></script>--%>
    <script src="assets/js/jquery-1.4.2.js" type="text/javascript"></script>
    <script src="assets/jquery/jquery-ui.min.js" type="text/javascript"></script>
    <script src="assets/jquery/jquery.dialog.extra.js" type="text/javascript"></script>
    <script type='text/javascript' src="assets/js/jquery-tab.min.js"></script>
    <script type='text/javascript' src="assets/js/jquery.bgiframe.min.js"></script>
    <script type='text/javascript' src="assets/js/jquery.ajaxQueue.js"></script>
    <script type='text/javascript' src="assets/js/thickbox-compressed.js"></script>
    <script type='text/javascript' src="assets/js/jquery.autocomplete.js"></script>
    <link rel="stylesheet" type="text/css" href="assets/css/datepicker.css" />
    <script type='text/javascript' src="assets/js/jquery.ui.datepicker.js"></script>
    <script type='text/javascript' src="Assets/js/jquery-custom-1.0.0.js?v=0611"></script>
    <script type='text/javascript' src="Assets/js/zoom.js"></script>
    <script type='text/javascript' src="assets/js/common.js"></script>
    <script type='text/javascript' src="Assets/js/encoder.js"></script>
    <script type='text/javascript' src="assets/js/DomesticPOR.js"></script>
    <script type='text/javascript' src="Assets/js/customeractive.js"></script>
    <link href="assets/jquery/jquery-ui.css" rel="stylesheet" type="text/css" />
    <link rel="stylesheet" type="text/css" href="assets/css/jquery.autocomplete.css" />
    <link rel="stylesheet" type="text/css" href="assets/css/thickbox.css" />
    <link rel="stylesheet" href="assets/css/reset.css" type="text/css" />
    <link rel="stylesheet" href="assets/css/styleexpress.css" type="text/css" />
    <link rel="stylesheet" href="assets/css/invalid.css" type="text/css" media="screen" />
    <link rel="stylesheet" href="Assets/css/EditTableCell.css" type="text/css" />
    <link rel="stylesheet" href="Assets/css/zoom.css" type="text/css" />
    <script type="text/javascript">
        var nPermissions = '<%=nPermissions %>';
        function doDelete(strID, strName) {
            if (confirm('Bạn có thực sự muốn xóa khách hàng "' + strName + '" ?')) {
                var vnpage = getUrlVars()['page_number'];
                if (vnpage)
                    window.location.href = "CustomerActive.aspx?action=delete&ID=" + strID + "&page_number=" + vnpage;
                else
                    window.location.href = "CustomerActive.aspx?action=delete&ID=" + strID;
            }
        }
        function openCustomerEdit(sId) {
            var url = 'CustomerActive.Edit.aspx';
            if (sId > 0)
                url += '?id=' + sId;
            window.open(url, 'CustomerActiveEdit', 'width=1100,height=700,scrollbars=no,resizable=no,toolbar=no,directories=no,location=no,menubar=no,status=no,left=0,top=0');

        }
        function CopyToCRM(sId) {
            if (confirm('Bạn có thực sự muốn thực hiện?')) {
                var vnpage = getUrlVars()['page_number'];
                if (vnpage)
                    window.location.href = "CustomerActive.aspx?action=copy&page_number=" + vnpage + "&id=" + sId;
                else
                    window.location.href = "CustomerActive.aspx?action=copy&id=" + sId;
                return true;
            }
            else {
                return false;
            }
        }
        function doImportCustomer() {
            var url = 'ImportCustomerActive.aspx';
            window.open(url, 'ImportCustomer', 'width=500,height=300,scrollbars=no,resizable=no,toolbar=no,directories=no,location=no,menubar=no,status=no,left=0,top=0');
        }
        function doCheckBulkDelete() {
            var listCust = $("#txtListCustomerID").val();
            if (listCust != ";") {
                if (confirm('Bạn có thực sự muốn xóa?')) {
                    var value = $("#txtTabID").val();
                    var vnpage = getUrlVars()['page_number'];
                    if (vnpage)
                        window.location.href = "CustomerActive.aspx?action=bulkdelete&page_number=" + vnpage + "&listCust=" + listCust;
                    else
                        window.location.href = "CustomerActive.aspx?action=bulkdelete" + "&listCust=" + listCust;
                    return true;
                }
                else {
                    return false;
                }
            }
            else {
                alert("Bạn phải chọn ít nhất một khách hàng!");
                return false;
            }
            return false;
        }
        function doCheckActive(active) {
            var listCust = $("#txtListCustomerID").val();
            if (listCust != ";") {
                if (confirm('Bạn có thực sự muốn thực hiện?')) {
                    var value = $("#txtTabID").val();
                    var vnpage = getUrlVars()['page_number'];
                    if (vnpage)
                        window.location.href = "CustomerActive.aspx?action=active&page_number=" + vnpage + "&archive=" + active + "&listCust=" + listCust;
                    else
                        window.location.href = "CustomerActive.aspx?action=active" + "&archive=" + active + "&listCust=" + listCust;
                    return true;
                }
                else {
                    return false;
                }
            }
            else {
                alert("Bạn phải chọn ít nhất một khách hàng!");
                return false;
            }
            return false;
        }
        function doSelectCustomer(custid) {
            var checked = document.getElementById("chbCustomer_" + custid).checked;
            var currentList = window.document.forms.frmCustomers.txtListCustomerID.value;
            if (currentList == "")
                currentList = ";";
            if (checked) {
                document.getElementById("txtListCustomerID").value = currentList + custid + ";";

            } else {
                document.getElementById("txtListCustomerID").value = currentList.replace(";" + custid + ";", ";");
            }
        }
        function checkAll() {
            var ajaxList = "#txtListCustomerIDAjaxLoad";
            var objName = "#checkall";
            var checked_status = $(objName).attr('checked');
            if (checked_status) {
                $("#txtListCustomerID").get(0).value = $(ajaxList).val();
                $(":checkbox.cbCustomer").attr('checked', true);
            }
            else {
                $("#txtListCustomerID").get(0).value = ';';
                $(":checkbox.cbCustomer").attr('checked', false);
            }
        }
        $(function () {
            $("#txtFrom").datepicker({ dateFormat: "dd-mm-yy" });
            $("#txtTo").datepicker({ dateFormat: "dd-mm-yy" });
        });
    </script>
    <style type="text/css">
        .thheader
        {
            font-weight: bold;
            vertical-align: middle;
            text-align: center;
            font-size: 11px;
            border: 1px solid #ccc !important;
            line-height: 12px !important;
        }
        .tdboder
        {
            border: none !important;
        }
        .tdboder p
        {
            padding: 1px !important;
            width: 40px;
            border: 1px solid #ccc !important;
            border-bottom: 1px solid #ccc !important;
        }
        .rdCustStyle
        {
            margin-left: 20px;
        }
        .rdCustStyle input
        {
            cursor: pointer;
        }
        .rdCustStyle table
        {
            border-collapse: separate !important; ;}</style>
</head>
<body>
    <div id="body-wrapper">
        <div id="header">
            <!--#include virtual="include/top.ascx"-->
        </div>
        <div id="main-content1">
            <h2>
                ACTIVE CUST
                <%if(nPermissions>=9) {%>
                <%if( TotalCust!=""){%>
                (Total:
                <%= TotalCust%>
                )
                <%}} %>
            </h2>
            <div class="clear">
            </div>
            <div class="content-box" zoomable="true">
                <form id="frmCustomers" runat="server">
                <div style="height: auto; padding: 7px;">
                    <asp:DropDownList ID="ddCustColor" runat="server" AutoPostBack="True" OnSelectedIndexChanged="ddCustColor_Selected">
                        <asp:ListItem Text="Mixed" Value="-1"></asp:ListItem>
                        <asp:ListItem Text="Blue" Value="0"></asp:ListItem>
                        <asp:ListItem Text="Red" Value="1"></asp:ListItem>
                    </asp:DropDownList>
                    <%if (Session["crSwitchExpImp"].ToString() == "0")
                          { %>
                    <asp:DropDownList class="cls" ID="drHsGoods" runat="server" Width="100px" TabIndex="16"
                        AutoPostBack="True" OnSelectedIndexChanged="drHsGoods_Selected">
                    </asp:DropDownList>
                    <asp:DropDownList class="cls" ID="drGoods" runat="server" Width="100px" TabIndex="16"
                        AutoPostBack="True" OnSelectedIndexChanged="drGoods_Selected">
                    </asp:DropDownList>
                    <%}
                          else
                          { %>
                    <asp:DropDownList class="cls" ID="drHsGoodsEx" runat="server" Width="100px" TabIndex="16"
                        AutoPostBack="True" OnSelectedIndexChanged="drHsGoodsEx_Selected">
                    </asp:DropDownList>
                    <asp:DropDownList class="cls" ID="drGoodsEx" runat="server" Width="100px" TabIndex="16"
                        AutoPostBack="True" OnSelectedIndexChanged="drGoodsEx_Selected">
                    </asp:DropDownList>
                    <%} %>
                    <asp:DropDownList ID="drCustUpdateTime" runat="server" AutoPostBack="true" OnSelectedIndexChanged="drCustUpdateTime_SelectedIndexChanged"
                        Visible="false">
                        <asp:ListItem Value="0" Text="TIME"></asp:ListItem>
                        <asp:ListItem Value="5" Text="5 ngày"></asp:ListItem>
                        <asp:ListItem Value="15" Text="15 ngày"></asp:ListItem>
                        <asp:ListItem Value="25" Text="25 ngày"></asp:ListItem>
                        <asp:ListItem Value="30" Text="30 ngày"></asp:ListItem>
                    </asp:DropDownList>
                    <asp:DropDownList class="cls" ID="ddPol" runat="server" Width="75px" TabIndex="16"
                        AutoPostBack="True" OnSelectedIndexChanged="ddPol_Selected">
                    </asp:DropDownList>
                    <asp:DropDownList class="cls" ID="ddPod" runat="server" Width="75px" TabIndex="16"
                        AutoPostBack="True" OnSelectedIndexChanged="ddPod_Selected">
                    </asp:DropDownList>
                    <asp:TextBox ID="txtSearchCustomerName" runat="server" value="TÊN KHÁCH HÀNG" Style="width: 210px;"
                        onclick="if(this.value=='TÊN KHÁCH HÀNG'){this.value=''; this.style.color='#000'}"
                        onblur="if(this.value==''){this.value='TÊN KHÁCH HÀNG'; this.style.color='#555'}"></asp:TextBox>
                    <asp:DropDownList ID="drByDistrict" runat="server" OnSelectedIndexChanged="drByDistrict_SelectedIndexChanged"
                        AutoPostBack="true" Width="80px">
                        <asp:ListItem Value="0" Text="PORT"></asp:ListItem>
                        <asp:ListItem Value="1" Text="Hải Phòng"></asp:ListItem>
                        <asp:ListItem Value="2" Text="Đà Nẵng"></asp:ListItem>
                        <asp:ListItem Value="3" Text="Hồ Chí Minh"></asp:ListItem>
                        <asp:ListItem Value="4" Text="Quy Nhơn"></asp:ListItem>
                        <asp:ListItem Value="5" Text="Cái Lân"></asp:ListItem>
                    </asp:DropDownList>
                    <asp:DropDownList class="cls" ID="ddType" runat="server" AutoPostBack="True" OnSelectedIndexChanged="ddType_Selected"
                        Width="80px">
                    </asp:DropDownList>
                    <asp:DropDownList class="cls" ID="ddDlvry" runat="server" AutoPostBack="True" OnSelectedIndexChanged="ddDlvry_Selected"
                        Width="80px">
                    </asp:DropDownList>
                    <asp:DropDownList class="cls" ID="ddCountry" runat="server" AutoPostBack="True" OnSelectedIndexChanged="ddCountry_Selected"
                        Width="120px">
                    </asp:DropDownList>
                    <asp:TextBox ID="txtFrom" CssClass="calendar-icon" runat="server" value="FROM" onclick="if(this.value=='FROM'){this.value=''; this.style.color='#000'}"
                        onblur="if(this.value==''){this.value='FROM'; this.style.color='#555'}" Width="80px"></asp:TextBox>
                    <asp:TextBox ID="txtTo" CssClass="calendar-icon" runat="server" value="TO" Width="80px"
                        onclick="if(this.value=='TO'){this.value=''; this.style.color='#000'}" onblur="if(this.value==''){this.value='TO'; this.style.color='#555'}"></asp:TextBox>
                    &nbsp;<asp:Button ID="btnSearch" runat="server" Text="&nbsp;Seach&nbsp;" CssClass="button"
                        OnClick="btnSearch_Click" />
                </div>
                <div class="clear">
                </div>
                <div class="content-box-header">
                    <h3 style="cursor: s-resize;">
                        <asp:LinkButton ID="lbtSwitchExpImp" runat="server" OnClick="lbtSwitchExpImp_Click"
                            Font-Bold="True" Font-Names="Tahoma" Font-Overline="False" Font-Strikeout="False"
                            Font-Size="14px" Font-Underline="True" Height="26px">HÀNG XUẤT KHẨU</asp:LinkButton>
                        <asp:Label ID="lblMessage" runat="server" CssClass="msg-error"></asp:Label>
                    </h3>
                    <div style="padding: 5px; float: right;">
                        <%if (nPermissions >= 3)
                      { %>
                        <a class="button" id="btnsave" href="#">Edit </a>&nbsp;
                        <%} %>
                        <%if (nPermissions >= 3)
                      { %>
                        <a class="button" href="#" onclick="openCustomerEdit();">Add New </a>&nbsp; <a class="button"
                            href="#" onclick="doImportCustomer();">Import Data </a>&nbsp;
                        <%} %>
                        <%if (nPermissions >= 9)
                      { %>
                        <a class="button" href="#" onclick="return doCheckBulkDelete();">Delete</a>
                        <%} %>
                    </div>
                </div>
                <div class="clear">
                </div>
                <fieldset>
                    <div autofit="true" style="">
                        <asp:Repeater ID="rptData" runat="server">
                            <ItemTemplate>
                                <tr onmouseover="this.style.background='#dbf0c9'" onmouseout="this.style.background='#ffffff'"
                                    cusid='<%#Eval("ID") %>'>
                                    <td align="center">
                                        <%# DataBinder.Eval(Container.DataItem, "Select")%>
                                    </td>
                                    <td align="center">
                                        <%# DataBinder.Eval(Container.DataItem, "LastUpdate")%>
                                    </td>
                                    <%if (Session["crSwitchExpImp"].ToString() == "0")
                                      { %>
                                    <td editable="true" code="HsGoods">
                                        <%# DataBinder.Eval(Container.DataItem, "HsGoods") %>
                                    </td>
                                    <td editable="true" code="Goods">
                                        <%# DataBinder.Eval(Container.DataItem, "Goods") %>
                                    </td>
                                    <%}
                                      else
                                      { %>
                                    <td editable="true" code="HsGoodsEx">
                                        <%# DataBinder.Eval(Container.DataItem, "HsGoodsEx") %>
                                    </td>
                                    <td editable="true" code="GoodsEx">
                                        <%# DataBinder.Eval(Container.DataItem, "GoodsEx") %>
                                    </td>
                                    <%} %>
                                    <td editable="true" code="Code">
                                        <%# DataBinder.Eval(Container.DataItem, "Code")%>
                                    </td>
                                    <td editable="true" code="Name" style="color: Blue; font-size: 12px;" class=' <%# Eval("Duplicate").ToString()=="1"?"red":"" %>'>
                                        <%# DataBinder.Eval(Container.DataItem, "Name") %>
                                    </td>
                                    <td editable="true" code="Address" completesource="por">
                                        <%# DataBinder.Eval(Container.DataItem, "Address")%>
                                    </td>
                                    <td editable="true" code="Mobile" style="display: none;">
                                        <%# DataBinder.Eval(Container.DataItem, "Mobile")%>
                                    </td>
                                    <td editable="true" code="Email" style="display: none;">
                                        <%# DataBinder.Eval(Container.DataItem, "Email")%>
                                    </td>
                                    <td editable="true" code="Social" style="display: none;">
                                        <%# DataBinder.Eval(Container.DataItem, "Social")%>
                                    </td>
                                    <td editable="true" code="Pol">
                                        <%# DataBinder.Eval(Container.DataItem, "Pol")%>
                                    </td>
                                    <td editable="true" code="Country">
                                        <%# DataBinder.Eval(Container.DataItem, "Country")%>
                                    </td>
                                    <td editable="true" code="Routers">
                                        <%# DataBinder.Eval(Container.DataItem, "Routers")%>
                                    </td>
                                    <%if (nPermissionTypeDlvry >0)
                                      {%>
                                    <td editable="true" code="Active_Type">
                                        <%# DataBinder.Eval(Container.DataItem, "Active_Type")%>
                                    </td>
                                    <%} %>
                                    <td editable="true" code="Active_Dlvry">
                                        <%# DataBinder.Eval(Container.DataItem, "Active_Dlvry")%>
                                    </td>
                                    <td editable="true" code="Vols">
                                        <%# DataBinder.Eval(Container.DataItem, "Vols")%>
                                    </td>
                                    <td editable="true" code="Report">
                                        <%# DataBinder.Eval(Container.DataItem, "Report")%>
                                    </td>
                                    <%if ( nPermissions > 7)
                                      {%>
                                    <td editable="true" code="Active_Cnee">
                                        <%# DataBinder.Eval(Container.DataItem, "Active_Cnee")%>
                                    </td>
                                    <%} %>
                                    <%if (nPermissions >= 1)
                                      {%>
                                    <td align="center">
                                        <div class="changed">
                                            <%# DataBinder.Eval(Container.DataItem, "Action") %>
                                        </div>
                                    </td>
                                    <%} %>
                                </tr>
                            </ItemTemplate>
                            <HeaderTemplate>
                                <table cellspacing="0" cellpadding="0" width="100%" border="0" class="adminlist"
                                    editcellcontent="true">
                                    <thead>
                                        <tr>
                                            <th align="center" class="thheader" width="50px" rowspan="2">
                                                <input type="checkbox" id="checkall" name="checkall" onclick="checkAll();" />
                                            </th>
                                            <th align="center" class="thheader" width="50px" rowspan="2">
                                                Date
                                            </th>
                                            <%if (Session["crSwitchExpImp"].ToString() == "0")
                                              { %>
                                            <th align="center" class="thheader resizeable" width="100px" colspan="2" onclick="SwichExportImport('Exp');"
                                                code="Exp">
                                                Hàng XK
                                            </th>
                                            <%}
                                              else
                                              { %>
                                            <th align="center" class="thheader resizeable" width="100px" colspan="2" onclick="SwichExportImport('Imp');"
                                                code="Imp">
                                                Hàng NK
                                            </th>
                                            <%} %>
                                            <th align="center" class="thheader resizeable" width="70px" rowspan="2">
                                                MKH
                                            </th>
                                            <th align="center" class="thheader resizeable" width="230px" rowspan="2">
                                                Tên C.ty khách hàng
                                            </th>
                                            <th align="center" class="thheader resizeable" width="120px" rowspan="2">
                                                Address
                                            </th>
                                            <th align="center" class="thheader resizeable" width="75px" style="display: none;"
                                                rowspan="2">
                                                Mobile
                                            </th>
                                            <th align="center" class="thheader resizeable" width="75px" style="display: none;"
                                                rowspan="2">
                                                Email
                                            </th>
                                            <th align="center" class="thheader resizeable" width="50px" style="display: none;"
                                                rowspan="2">
                                                Social
                                            </th>
                                            <th align="center" class="thheader resizeable" width="75px" rowspan="2">
                                                POL
                                            </th>
                                            <th align="center" class="thheader resizeable" rowspan="2">
                                                Country
                                            </th>
                                            <th align="center" class="thheader resizeable" width="75px" rowspan="2">
                                                POD
                                            </th>
                                            <%if (nPermissionTypeDlvry >0)
                                             {%>
                                            <th align="center" class="thheader resizeable" rowspan="2">
                                                Type
                                            </th>
                                            <%} %>
                                            <th align="center" class="thheader resizeable" rowspan="2">
                                                Dlvr
                                            </th>
                                            <th align="center" class="thheader resizeable" rowspan="2">
                                                20'
                                            </th>
                                            <th align="center" class="thheader resizeable" rowspan="2">
                                                40'
                                                <%--Report--%>
                                            </th>
                                            <%if (nPermissions > 7)
                                              {%>
                                            <%if (Session["crSwitchExpImp"].ToString() == "0")
                                              { %>
                                            <th align="center" class="thheader resizeable" rowspan="2" width="150px">
                                                Cnee
                                            </th>
                                            <%}
                                              else
                                              { %>
                                            <th align="center" class="thheader resizeable" rowspan="2" width="150px">
                                                Shpr
                                            </th>
                                            <%} %>
                                            <%} %>
                                            <%if (nPermissions >= 1)
                                              {%>
                                            <th class="thheader" width="50px" rowspan="2">
                                                Action
                                            </th>
                                            <%} %>
                                        </tr>
                                        <tr>
                                            <%if (Session["crSwitchExpImp"].ToString() == "0")
                                              { %>
                                            <th class="thheader resizeable" width="50px" code="Exp">
                                                CODE
                                            </th>
                                            <th class="thheader resizeable" width="100px" code="Exp">
                                                XK
                                            </th>
                                            <%}
                                              else
                                              { %>
                                            <th class="thheader resizeable" width="50px" code="Imp">
                                                CODE
                                            </th>
                                            <th class="thheader resizeable" width="100px" code="Imp">
                                                NK
                                            </th>
                                            <%} %>
                                        </tr>
                                    </thead>
                            </HeaderTemplate>
                            <FooterTemplate>
                                <%if (Session["seacrhByCustomerName"]!=null)
                                  {
                                      int cont20 = 0, cont40 = 0, volsExt = 0;
                                      GetTotalVolByCustomerName(Session["seacrhByCustomerName"].ToString(), out cont20, out cont40, out volsExt);
                                      if (cont20 > 0 || cont40 > 0 || volsExt > 0)
                                      {%>
                                <tr>
                                    <%if (nPermissionTypeDlvry >0)
                                             {%>
                                    <td colspan="12" style="text-align: right; font-weight: bold; padding-right: 20px !important;">
                                        Tổng cộng
                                    </td>
                                    <%}else{ %>
                                    <td colspan="11" style="text-align: right; font-weight: bold; padding-right: 20px !important;">
                                        Tổng cộng
                                    </td>
                                    <%} %>
                                    <td>
                                        <%Response.Write(cont20.ToString()); %>
                                    </td>
                                    <td>
                                        <%Response.Write(cont40.ToString()); %>
                                    </td>
                                    <%if (nPermissions > 7)
                                              {%>
                                    <td>
                                    </td>
                                    <%} %>
                                    <td colspan="2">
                                    </td>
                                </tr>
                                <%}
                                  }%>
                                </TABLE>
                            </FooterTemplate>
                        </asp:Repeater>
                    </div>
                </fieldset>
                <div class="clear">
                </div>
                <div id="footer">
                    <%=strPager%>
                </div>
                <input type="hidden" id="txtListCustomerIDAjaxLoad" value="<%=strListCustIDAjaxLoad %>">
                <input type="hidden" id="txtListCustomerID" name="txtListCustomerID" runat="server"
                    value=";" />
                </form>
            </div>
        </div>
    </div>
</body>
</html>
